package com.coc.serviceimpl.sysProvince;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.coc.dao.sysProvince.SysAreaDao;
import com.coc.dao.sysProvince.SysCityDao;
import com.coc.dao.sysProvince.SysProvinceDao;
import com.coc.dao.sysProvince.SysStreetDao;
import com.coc.entity.sysProvince.SysArea;
import com.coc.entity.sysProvince.SysCity;
import com.coc.entity.sysProvince.SysProvince;
import com.coc.entity.sysProvince.SysStreet;
import com.coc.service.sysProvince.SysProvinceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 省份设置(SysProvince)表服务实现类
 *
 * @author songju
 * @since 2020-03-06 14:01:03
 */
@Service("sysProvinceService")
public class SysProvinceServiceImpl extends ServiceImpl<SysProvinceDao, SysProvince> implements SysProvinceService {
    @Autowired
    private SysAreaDao sysAreaDao;
    @Autowired
    private SysCityDao sysCityDao;
    @Autowired
    private SysStreetDao sysStreetDao;


    @Override
    public List<SysProvince> getProLists() {
        List<SysProvince> provinces = this.list();
        //List<SysArea> sysAreas = sysAreaDao.selectList(new QueryWrapper<>());
        List<SysCity> sysCities = sysCityDao.selectList(new QueryWrapper<>());
       // List<SysStreet> sysStreets = sysStreetDao.selectList(new QueryWrapper<>());
        ArrayList<SysCity> sysCities1=null;
        ArrayList<SysArea> sysAreas1 =null;
        ArrayList<SysStreet> sysStreets1 =null;
        for (SysProvince sysp:provinces){
            for (SysCity sysc:sysCities){
                if (sysc.getProvinceCode().equals(sysp.getProvinceCode())){
                    sysCities1 = new ArrayList<>();
                    sysCities1.add(sysc);
                }
                /*sysAreas1 = new ArrayList<>();
                for (SysArea sysArea:sysAreas){
                    if (sysc.getCityCode().equals(sysArea.getCityCode())){
                        sysAreas1.add(sysArea);
                    }
                    sysStreets1=new ArrayList<>();
                    for (SysStreet syss:sysStreets){
                        if (sysArea.getAreaCode().equals(syss.getAreaCode())){
                            sysStreets1.add(syss);
                        }
                    }
                }*/
            }
            sysp.setSysCityList(sysCities1);
        }

        return provinces;
    }
}